package com.company.最大匹配;

import java.util.Arrays;

public class Leet2576 {
    private int[]nums,pj;
    private boolean findP(int i,boolean[] v){
        if(i == 0)return true;
        for(int j = 0;j<pj.length;j++){
            if(nums[i]>=nums[j]*2&&!v[j]){
                v[j]=true;
                if(findP(pj[j],v)){
                    pj[j] = i;
                    return true;
                }
            }
        }
        return false;
    }
    public int maxNumOfMarkedIndices(int[] nums) {
        Arrays.sort(nums);
        this.nums = nums;
        int k = nums.length/2;
        if(k==0)return 0;
        pj = new int[k];
        int count = 0;
        for(int i = k;i<nums.length;i++){
            if(findP(i,new boolean[k])){
                count+=2;
            }
        }
        return count;
    }
}
